#version 460
#extension GL_GOOGLE_include_directive : enable

#include "../../../core/shader_binding_ID.h"

layout(location = 1) in GS_FS_VERTEX {
	flat vec4	vColor;
	flat vec2	vUV_Offset;
	flat float	vUV_Bound;
	flat float	vUV_z;

	flat int	gTexType;
};

layout(location=0) out vec4 outColor;

layout(binding = DEF_BINDING_WIDGET_Texture) uniform sampler2DArray tex;
layout(binding = DEF_BINDING_WIDGET_Texture + 1) uniform sampler2DArray tex_background;

void main(void){
	vec3 c = vec3(0.5, 0.2, 0.2);

	switch(gTexType){
		case 0:{
			float a = texture(tex_background, vec3(gl_PointCoord, vUV_z), 0).r;
			outColor = vec4(c, 1);
			break;
		}
		case 1:{
			vec3 uv = vec3(gl_PointCoord * vUV_Bound, vUV_z);
			uv.xy += vUV_Offset.xy;
			float a = texelFetch(tex, ivec3(uv), 0).r;
			outColor = vec4(mix(c, vColor.rgb, a), 1);
			break;
		}
		case 2:{
			outColor = vColor;
			break;
		}
	}
	
	
}

 